const Controller = require('egg').Controller;
class AuditController extends Controller {
	async audit() {
		const {
			ctx
		} = this
		const data = await ctx.service.audit.audit()
		ctx.body = {
			code: 1,
			data
		}
	}
	async delAudit() {
		const {
			ctx
		} = this
		const data = await ctx.service.audit.delAudit()
		if (data.affectedRows >= 1) {
			ctx.body = {
				code: 1,
				message: '删除成功'
			}
		} else {
			ctx.body = {
				code: 0,
				message: '删除失败'
			}
		}
	}
	async addAudit() {
		const {
			ctx
		} = this
		const data = await ctx.service.audit.addAudit()
		if (data.affectedRows >= 1) {
			ctx.body = {
				code: 1,
				message: '添加成功'
			}
		} else {
			ctx.body = {
				code: 0,
				message: '添加失败'
			}
		}
	}
	async editAudit() {
		const {
			ctx
		} = this
		const data = await ctx.service.audit.editAudit()
		if (data.affectedRows >= 1) {
			ctx.body = {
				code: 1,
				message: '编辑成功'
			}
		} else {
			ctx.body = {
				code: 0,
				message: '编辑失败'
			}
		}
	}
}

module.exports = AuditController;